package plus.exp;

import plus.Gripe;
import plus.Type;
import plus.run.Label;

public abstract class Exp {
	Type type;
	public abstract void threadScope();
	abstract String impliedName();
	public Type unify_with(Type o) { return type = Type.unify(type, o); }
	public Type unify_with(Exp o) { return type = o.type = Type.unify(type, o.type); }
	void checkThread() {
		if (null==type) {
			throw new RuntimeException("threadScope() failed to set type in "+getClass());
		}
	}
	public void threadAssign() {
		// General case is that you can't assign.
		throw new Gripe("Can't assign to "+aThis());
	}
	abstract String aThis();
	public abstract void compilePush();
	public void compileJcc(Label where, boolean when) { compilePush(); where.Jcc(when); }
	public void compileAssign(Exp rhs) {
		// General case is that you can't assign.
		throw new Gripe("Can't assign to "+aThis());
	}
}
